<template>
    <section>
        <el-table :data="tableData" stripe v-loading="loading">
            <el-table-column type="index" width="50" label="#" align="center" />
            <el-table-column prop="csId" width="210" label="投诉ID" />
            <el-table-column prop="district" width="100" label="区县" />
            <el-table-column prop="category" label="投诉类别" width="100" align="center" />
            <el-table-column prop="subCategory" label="投诉子类别" width="150" align="center" />
            <el-table-column prop="gridName" label="网格名称" width="120" align="center" />
            <el-table-column prop="phoneNumer" label="手机号" width="130" align="center" />
            <el-table-column prop="operatingState" label="操作状态" width="80" align="center" />
            <el-table-column label="分发时间" min-width="150">
                <template #default="scope">
                    {{ getFormulateDate(scope.row.dispatchTime) }}
                </template>
            </el-table-column>
        </el-table>
    </section>
</template>

<script setup>
import { ref, computed, defineProps } from 'vue'
import { getFormulateDate } from "@/utils/index.js";
import { queryCellComplaintList } from "@/api/complain/complain";

const tableData = ref([])

let loading = ref(false);

const props = defineProps({
    baseData: {
        type: Object,
        default: () => { },
    }
})

const getPopupData = () => {
    // console.log('投诉信息', props.baseData)
    loadCellComplaintList()
}

const loadCellComplaintList = () => {
    loading.value = true;
    const { cgi } = props.baseData;
    //获取明天的日期
    let currentDate = new Date();
    // 增加一天
    currentDate.setDate(currentDate.getDate() + 1);
    // 将时间部分设置为午夜（00:00:00）
    currentDate.setHours(0, 0, 0, 0);

    // 创建一个新的Date对象，表示当前日期和时间
    let currentDate1 = new Date();

    // 获取当前年份和月份
    let year = currentDate1.getFullYear();
    let month = currentDate1.getMonth(); // 注意：getMonth() 返回的月份是从0开始的（0=一月, 11=十二月）

    // 设置日期为当前月份的第一天，时间设置为午夜
    let firstDayOfMonth = new Date(year, month, 1, 0, 0, 0, 0);

    let param = {
        cgi: cgi,
        startTime: firstDayOfMonth,
        endTime: currentDate
    }
    queryCellComplaintList(param).then(res => {
        loading.value = false;
        tableData.value = res.data;
    })
}

loadCellComplaintList()

defineExpose({
    getPopupData,
});
</script>

<style lang="scss" scoped></style>